/*
 * Usage:
 * 该文件为主控制器，用于实现MyWebServer与各个控制器函数的交互，其作用类似于一个中枢
 * 每在Controllers.cpp中增加一个Controller函数，就要将其在主控制器中进行注册
 * 每一个控制器函数传入的参数为C++的string，表示请求的参数
 * 返回值应该为C++的string，表示一个json格式的字符串，用于前端的解析
 */

#include "MainController.h"

string mainController(string controllerName, string params) {
    if (controllerName == "testController") {
	printf("[MainController-INFO] send request to testController\n");
        return testController(params);
    } else if (controllerName == "testController2"){
	printf("[MainController-INFO] send request to testController2\n");
	return testController2(params);
    } else if (controllerName == "getTableContent"){
	printf("[MainController-INFO] send request to getTableContent\n");
	return getTableContent(params);
    } else if (controllerName == "insertIntoTable"){
	printf("[MainController-INFO] send request to insertIntoTable\n");
	return insertIntoTable(params);
    } else if (controllerName == "getAllTableName"){
	printf("[MainController-INFO] send request to getAllTableName\n");
	return getAllTableName(params);
    } else if (controllerName == "createOneTable"){
	printf("[MainController-INFO] send request to createOneTable\n");
	return createOneTable(params);
    }else if (controllerName == "dropOneTable"){
        printf("[MainController-INFO] send request to dropOneTable\n");
        return dropOneTable(params);
    }else if (controllerName == "deleteFromTable"){
        printf("[MainController-INFO] send request to deleteFromTable\n");
        return deleteFromTable(params);
    } else if (controllerName == "updateTable"){
        printf("[MainController-INFO] send request to updateTable\n");
        return updateTable(params);
    }
    else {
        printf("[MainController-ERROR] no such controller\n"/*, controllerName.c_str()*/);
        return string("");
    }
}
